package io.github.talelin.latticy.vo;

import io.github.talelin.latticy.entity.SendCollect;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
public class SendCollectFlowerVO
{
    private Long id;
    private String image;
    private String title;
    private String name;
    private String video;

    public SendCollectFlowerVO (SendCollect sendCollect)
    {
//        this.setId(sendCollect.getId());
        if (sendCollect.getFlower() != null) {
            this.setImage(sendCollect.getFlower().getImage());
            this.setTitle(sendCollect.getFlower().getTitle());
            this.setName(sendCollect.getFlower().getName());
        }
        BeanUtils.copyProperties(sendCollect, this);
    }

    public static List<SendCollectFlowerVO> getLists(List<SendCollect> sendCollects)
    {
        return sendCollects.stream()
                .map(SendCollectFlowerVO::new)
                .collect(Collectors.toList());
    }
}
